package demo;

import java.util.Arrays;

class Student implements Comparable<Student>{
    public int age;
    public String name;
    public int score;

    public Student(int age, String name, int score) {
        this.age = age;
        this.name = name;
        this.score = score;
    }

    @Override
    public int compareTo(Student o) {
        return this.age-o.age;
    }

    @Override
    public String toString() {
        return "Student{" +
                "age=" + age +
                ", name='" + name + '\'' +
                ", score=" + score +
                '}';
    }
}

public class Test {

    public static void main(String[] args) {
        Student[] student = new Student[3];
        student[0] = new Student(10,"Zhangsan",80);
        student[1] = new Student(30,"Lisi",90);
        student[2] = new Student(20,"Wangerma",85);
        Arrays.sort(student);
        System.out.println(Arrays.toString(student));

    }
}
